﻿namespace FunctionalCLR.Core {
    public abstract class AbstractParserFactory : IParserFactory {

        public abstract Parser CreateParser(string expr);

        public abstract Parser CreateParser(string expr, object context);

        public virtual object Evaluate(string expr) {
            Parser parser = CreateParser(expr);
            Node root = parser.Parse();
            object result = root.Evaluate();

            return result;
        }

        public virtual object Evaluate(string expr, object context) {
            return this.Evaluate(expr);
        }
    }
}
